package com.qk.management.handler;


import com.qk.common.Result;
import com.qk.common.exception.CommonException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler
    public Result ex(Exception e){//方法形参中指定能够处理的异常类型
        //捕获到异常之后，响应一个标准的Result
        return Result.error("对不起,操作失败,请联系管理员");
    }
    @ExceptionHandler(value = CommonException.class)
    public Result handleCommonException(CommonException e) {
        return Result.error(e.getMessage());
    }
}
